]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st/theme-node: Free properties array on dispose rather than finalize
authorJonas Dreßler <verdre@v0yd.nl>
Thu, 24 Jul 2025 17:47:58 +0000 (19:47 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 13 Sep 2025 17:02:58 +0000 (19:02 +0200)
We're going to use `g_object_run_dispose()` on StThemeNode with the next
commit in order to manually clear the properties array and a few other
things when the StThemeContext changes.

That's because after theme context changes, the CSS properties will no
longer be valid, and accessing them will cause crashes. Even if St behaves
nicely and throws out all theme nodes on theme context changes, there
might still be users holding references to nodes, so we want to ensure that
the old nodes are harmless after theme context changes.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3809>
(cherry picked from commit 07d6cf017eedfa02059848b33a5412576ac023c6)

src/st/st-theme-node.c

index 4e0111d4f94b495a6aecfaf52dfc0ddeba330398..8fbb71a107454ba8b568d4e05417d4cc6b7991ff 100644 (file)
@@ -102,6 +102,7 @@ st_theme_node_dispose (GObject *gobject)
 
   st_theme_node_paint_state_free (&node->cached_state);
 
+  maybe_free_properties (node);
   g_clear_object (&node->theme);
 
   G_OBJECT_CLASS (st_theme_node_parent_class)->dispose (gobject);
@@ -117,8 +118,6 @@ st_theme_node_finalize (GObject *object)
   g_strfreev (node->pseudo_classes);
   g_free (node->inline_style);
 
-  maybe_free_properties (node);
-
   g_clear_pointer (&node->font_desc, pango_font_description_free);
 
   g_clear_pointer (&node->box_shadow, st_shadow_unref);